﻿<sdk:Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:AdventureWorksLT.Views.Customers.ViewModels" 
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:E2C="clr-namespace:AdventureWorksLT.Core"
xmlns:appControls="clr-namespace:AdventureWorksLT.Controls"
xmlns:xControls="clr-namespace:AdventureWorksLT.Views.Customers.Controls" 
x:Class="AdventureWorksLT.Views.Customers.WorkWith.CustomerWorkWithGrid"
mc:Ignorable="d"
d:DesignWidth="840" d:DesignHeight="480"
Title="Customer WorkWithGrid"
>
    <sdk:Page.Resources>
        <viewModels:CustomersViewModel x:Key="CustomersViewModel" />
    </sdk:Page.Resources>
    <appControls:BusyIndicator x:Name="BusyIndicator" BusyContent="Loading Customers data...." DataContext="{Binding Source={StaticResource CustomersViewModel}}" FontSize="18" IsBusy="{Binding IsBusy}">
        <ScrollViewer x:Name="scrollViewerCustomer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
            <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource CustomersViewModel}}" Background="#FF8D8C89" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="2" />
                    <RowDefinition Height="300*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions >
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="230*" />
                </Grid.ColumnDefinitions>
                <ScrollViewer Grid.Column="1" Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
                    <StackPanel   HorizontalAlignment="Left" Orientation="Vertical" VerticalAlignment="Top"  Margin="2">
                        <Button Background="#FF6BB6F7" x:Name="ShowSalesOrderHeaderButton" Content="Sales Order Header" Width="200" Margin="2"   Height="30" FontSize="11" Click="GoToSalesOrderHeaderButtonClick"  />
                        <Button Background="#FF6290CE" x:Name="ShowCustomerButton" Content="Customer" Width="200" Margin="2"   Height="30" FontSize="11" Click="GoToCustomerButtonClick" />
                    </StackPanel>
                </ScrollViewer>
                <StackPanel Grid.Column="0" Grid.Row="1" Orientation="Vertical" VerticalAlignment="Top" Width="Auto">
                    <StackPanel  Orientation="Horizontal" VerticalAlignment="Top" Width="Auto">
                        <Button Content="Previous" HorizontalAlignment="Left" Height="27"  VerticalAlignment="Top" Width="100" Command="{Binding PreviousPageCommand}" Background="#FF62A3DB" Foreground="Yellow" Margin="3" FontFamily="Arial" FontSize="13.333" ></Button>
                        <Button Content="Next" HorizontalAlignment="Left" Height="27"  VerticalAlignment="Center" Width="100" Command="{Binding NextPageCommand}" Background="#FF62A3DB" Foreground="Yellow" FontFamily="Verdana" FontSize="13.333" Margin="3" ></Button>
                    </StackPanel>
                    <!--start of the Datagrid-->
                    <sdk:DataGrid Style="{StaticResource DataGridCellJetPackStyle}" CellStyle="{StaticResource LeftCell}" ColumnHeaderStyle="{StaticResource DataGridColumnHeader}" RowHeaderStyle="{StaticResource DataGridRowHeader}" RowStyle="{StaticResource DataGridRow}" AutoGenerateColumns="False" IsReadOnly="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding Source={StaticResource CustomersViewModel}}" ItemsSource="{Binding CustomersCollection, Mode=TwoWay}" x:Name="CustomersDataGrid" >
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <E2C:EventToCommand Command="{Binding SelectionChangedSdkCommand}" CommandParameter="{Binding SelectedItem, ElementName=CustomersDataGrid}" ></E2C:EventToCommand>
                            </i:EventTrigger>
                            <i:EventTrigger EventName="LoadingRow">
                                <E2C:EventToCommand Command="{Binding RowLoadingSdkCommand}" PassEventArgsToCommand="True" ></E2C:EventToCommand>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <!--start of Tab-->
                        <sdk:DataGrid.RowDetailsTemplate >
                            <DataTemplate  >
                                <sdk:TabControl Height="150" Width="Auto" HorizontalAlignment="Left" VerticalAlignment="Stretch" >
                                    <sdk:TabItem >
                                        <ScrollViewer>
                                            <StackPanel Orientation="Vertical">
                                                <xControls:SalesOrderHeaderWorkWithGrid></xControls:SalesOrderHeaderWorkWithGrid>
                                            </StackPanel>
                                        </ScrollViewer>
                                    </sdk:TabItem>
                                </sdk:TabControl>
                            </DataTemplate>
                        </sdk:DataGrid.RowDetailsTemplate>
                        <!--End of Tab-->
                        <!--Start buttons-->
                        <sdk:DataGrid.Columns >
                            <sdk:DataGridTemplateColumn x:Name="printRow" Width="20">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="p" ToolTipService.ToolTip="Print This Customers" DataContext="{Binding Source={StaticResource CustomersViewModel}}">
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <E2C:EventToCommand Command="{Binding PrintCommand}" CommandParameter="{Binding SelectedItem, ElementName=CustomersDataGrid}" ></E2C:EventToCommand>
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </Button>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn x:Name="addRow" Width="20">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="+" ToolTipService.ToolTip="Add a new Customers" DataContext="{Binding Source={StaticResource CustomersViewModel}}" >
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <E2C:EventToCommand Command="{Binding AddNewCommand}" CommandParameter="{Binding SelectedItem, ElementName=CustomersDataGrid}" ></E2C:EventToCommand>
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </Button>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn x:Name="deleteRow" Width="20">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="-" ToolTipService.ToolTip="Delete This Customers" DataContext="{Binding Source={StaticResource CustomersViewModel}}" >
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <E2C:EventToCommand Command="{Binding DeleteCommand}" CommandParameter="{Binding SelectedItem, ElementName=CustomersDataGrid}" ></E2C:EventToCommand>
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </Button>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <sdk:DataGridTemplateColumn x:Name="ModifyRow" Width="20">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="..." ToolTipService.ToolTip="Modify This Customers" DataContext="{Binding Source={StaticResource CustomersViewModel}}" >
                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="Click">
                                                    <E2C:EventToCommand Command="{Binding EditCurrentInNewWindowCommand}" CommandParameter="{Binding SelectedItem, ElementName=CustomersDataGrid}" ></E2C:EventToCommand>
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>
                                        </Button>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>
                            <!--End buttons-->
                            <sdk:DataGridTextColumn x:Name="idColumn" Binding="{Binding Path=CustomerID}" Header="Id" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="NameStyleColumn" Binding="{Binding Path=NameStyle}" Header="Name Style" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="TitleColumn" Binding="{Binding Path=Title}" Header="Title" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="FirstNameColumn" Binding="{Binding Path=FirstName}" Header="First Name" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="MiddleNameColumn" Binding="{Binding Path=MiddleName}" Header="Middle Name" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="LastNameColumn" Binding="{Binding Path=LastName}" Header="Last Name" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="SuffixColumn" Binding="{Binding Path=Suffix}" Header="Suffix" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="CompanyNameColumn" Binding="{Binding Path=CompanyName}" Header="Company Name" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="SalesPersonColumn" Binding="{Binding Path=SalesPerson}" Header="Sales Person" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="EmailAddressColumn" Binding="{Binding Path=EmailAddress}" Header="Email Address" Width="SizeToHeader" />
                            <sdk:DataGridTextColumn x:Name="PhoneColumn" Binding="{Binding Path=Phone}" Header="Phone" Width="SizeToHeader" />
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                    <!--End of the Datagrid-->
                </StackPanel>
            </Grid>
        </ScrollViewer>
    </appControls:BusyIndicator>
</sdk:Page>
